package com.ks.zuul;


import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
import springfox.documentation.swagger.web.SwaggerResource;
import springfox.documentation.swagger.web.SwaggerResourcesProvider;

import java.util.ArrayList;
import java.util.List;

@EnableZuulProxy
@SpringBootApplication
public class ApiGatewayApplication {
    public static void main(String[] args) {
        SpringApplication.run(ApiGatewayApplication.class, args);
    }


    @Component
    @Primary
    class GetWayResource implements SwaggerResourcesProvider {


        @Override
        public List<SwaggerResource> get() {
            List<SwaggerResource> resources = new ArrayList<>();
            resources.add(swaggerResource("基础数据服务", "/base-service/v2/api-docs", "1.0"));
            resources.add(swaggerResource("用户服务", "/user-service/v2/api-docs", "1.0"));
            resources.add(swaggerResource("微报修服务", "/repair-service/v2/api-docs", "1.0"));
            resources.add(swaggerResource("服务网点服务", "/network-service/v2/api-docs", "1.0"));
            resources.add(swaggerResource("信息发布服务", "/cms-service/v2/api-docs", "1.0"));
            resources.add(swaggerResource("微会员服务", "/member-service/v2/api-docs", "1.0"));
            resources.add(swaggerResource("裂变服务", "/fission-service/v2/api-docs", "1.0"));
            resources.add(swaggerResource("模板引擎服务", "/template-service/v2/api-docs", "1.0"));
            resources.add(swaggerResource("转评赞服务", "/comment-service/v2/api-docs", "1.0"));
            return resources;
        }

        private SwaggerResource swaggerResource(String name, String location, String version) {
            SwaggerResource swaggerResource = new SwaggerResource();
            swaggerResource.setName(name);
            swaggerResource.setLocation(location);
            swaggerResource.setSwaggerVersion(version);
            return swaggerResource;
        }
    }
}
